#pragma once
#include"RBTree.h"

namespace dan
{
	template<class K>
	class set
	{
		struct SetKeyOfT
		{
			const K& operator()(const K& k)
			{
				return k;
			}
		};

	public:
		typedef typename RBTree<K,const K, SetKeyOfT>::Iterator iterator;
		typedef typename RBTree<K,const K, SetKeyOfT>::ConstIterator const_iterator;

		iterator begin()
		{
			return _t.Begin();
		}

		iterator end()
		{
			return _t.End();
		}

		const_iterator begin()const
		{
			return _t.Begin();
		}

		const_iterator end()const
		{
			return _t.End();
		}

		pair<iterator,bool> insert(const K& k)
		{
			return _t.Insert(k);
		}
	private:
		RBTree<K,const K,SetKeyOfT> _t;
	};
}

void test_set()
{
	dan::set<int> s;
	s.insert(4);
	s.insert(14);
	s.insert(2);
	s.insert(23);
	s.insert(12);
	s.insert(29);
	s.insert(231);

	dan::set<int>::iterator it = s.begin();
	while (it != s.end())
	{
		cout << *it << ' ';
		++it;
	}
	cout << endl;

	//dan::set<int>::iterator it1 = s.end();
	//while (it1 != s.begin())
	//{
	//	cout << *it1 << ' ';
	//	--it1;
	//}
	//cout << endl;

}
